package com.nabton.ndscollector.database;

import java.util.List;

public final class DatabaseHelper 
{
	private DatabaseHelper()
	{
		
	}

	public static String createTableQuery(
        String tableName,
        List<String> tableDef)
	{
        String query = "CREATE TABLE IF NOT EXISTS ";
        query += tableName;
        query += " (";
        
        for (String column : tableDef)
        {
        	query += column + ", ";
        }
        
        query = query.substring(0,query.length()-2)+")";

        return query;
	}
	
   public static String createExistsTableQuery(
       String tableName)
   {
       String query = "SELECT count(name)";
       query += " FROM sqlite_master";
       query += " WHERE";
       query += " type='table'";
       query += " AND name='"+tableName+"'";

       return query;
   }
   
   public static String createSelectAllNewControlMessagesQuery(
       String tableName)
   {
       String query = "SELECT *";
       query += " FROM ";
       query += tableName;
       query += " WHERE status = 'NEW'";
       return query;
   }
   
   public static String createInsertQuery(
       String tableName,
       double data,
       String time)
   {
       //INSERT INTO TABLE_NAME VALUES (value1,value2,value3,...valueN);
       String query = "INSERT INTO ";
       query += tableName;
       query += " VALUES (";
       query += data+",";
       query += "'"+time+"'";
       query += ")";
       
       return query;
   }
	
}
